package app

import (
	"gin-app/app/common/response"
	"gin-app/app/services"
	"github.com/dgrijalva/jwt-go"
	"github.com/gin-gonic/gin"
)

func Info(c *gin.Context) {

	err, user := services.UserService.GetUserInfo(c.Keys["id"].(string))
	if err != nil {
		response.BusinessFail(c, err.Error())
		return
	}
	response.Success(c, user)
}

func Logout(c *gin.Context) {
	err := services.JwtService.JoinBlackList(c.Keys["token"].(*jwt.Token))
	if err != nil {
		response.BusinessFail(c, "登出失败")
		return
	}
	response.Success(c, nil)
}
